package com.vates.ejercitacion;

import java.util.*;

public class Lifo implements Pila {
	
	ArrayList <Object> lifo=new ArrayList<Object>();
	
	public boolean cargar(Object o){//Cargar la pila lifo.
		
		if (lifo.add(o) == true)
        {
            return true;
        }
        return false;
	}
	
	public boolean eliminar(Object o){ //eliminar un elemento de la pila lifo y lo muestra.
		//lifo.get(lifo.size());
		if(lifo.isEmpty()!=true){
		lifo.lastIndexOf(o);
		return lifo.remove(o);
		//return true;
		}
		return false;
	}
	
	public void listar(){
		
		  Iterator<Object> iterator = lifo.iterator();
	        while (iterator.hasNext())
	        {
	            System.out.println(iterator.next().toString());

	        }
	}

}
